﻿
var U = undefined;
var i = window.location.href.indexOf(".com");
var g_domainURL = window.location.href.substring(0, i + 4);
g.dragEle = undefined;
g.initialOffsetX = 0;
g.initialOffsetY = 0;
g.volatileArray = new Array;
g.dataWebTable = new Array;
g.WebTable = new Array;
g.Category = new Array;
g.state = {};
g.state["search"] = false;
g.returnFalse = function () {
    return false;
}
function voidFun() {
    if (!e) e = lib.getEvent();
    e = EventUtil.formatEvent(e);
    if (e.stopPropagation) e.stopPropagation();
    else e.cancelBubble = true;
    return false;
}
window.onresize = function () {
    g.page.r();
};
if (!Array.prototype.forEach) {
    Array.prototype.forEach = function (fun) {
        var len = this.length;
        if (typeof fun != "function")
            throw new TypeError();
        var thisp = arguments[1];
        for (var i = 0; i < len; i++) {
            if (i in this)
                fun.call(thisp, this[i], i, this);
        }
    };
}
if (!Array.indexOf) {
    Array.prototype.indexOf = function (obj) {
        for (var i = 0; i < this.length; i++) {
            if (this[i] == obj) {
                return i;
            }
        }
        return -1;
    }
}
Object.prototype.on = function (type, callback) {
    if (this.attachEvent) {
        this.attachEvent("on" + type, callback);
    } else if (this.addEventListener) {
        this.addEventListener(type, callback, false);
    }
}
Object.prototype.off = function (type, callback) {
    if (this.attachEvent) {
        this.detachEvent("on" + type, callback);
    } else if (this.addEventListener) {
        this.removeEventListener(type, callback, false);
    }
}
if (!document.on) {
    document.on = Object.prototype.on;
    document.off = Object.prototype.off;
}
function $(obj) {
    if (typeof obj == "string") {
        obj = document.getElementById(obj);
    }
    if (obj && !obj.on) {
        obj.on = Object.prototype.on;
        obj.off = Object.prototype.off;
    }
    return obj;
}
function u(p) {
    return (p == U) ? true : false;
}
function funForCateEleClick() {
    window.force.open("urlredirect.aspx?url=" + g.mouseEvent.target.getAttribute("Link"), '', '');
}
function funForWebEleClick() {
    window.force.open(g.mouseEvent.target.getAttribute("Link"), '', '');
}
function funForWebEleDblclick() {
    var t = new EditWeb(getDataByMouse(g.mouseEvent).webData);
}
function oneLayerClone(source) {
    var tmp = {};
    for (var i in source) {
        tmp[i] = source[i];
    }
    return tmp;
}
function arrayContainer(p) {
    var _ = this;
    _.arr = new Array;
    _.length = p;
    _.push = function (value) {
        _.arr.push(value);
        if (_.arr.length > _.length) {
            _.arr.splice(0, 1);
        }
    };
    _.clear = function () {
        _.arr.length = 0;
    };
}
var eventHandler =
{
    eventType: -1,
    isMove: false,
    g_eventArray: new arrayContainer(10),
    paramForMousedown: U,
    paramForMouseup: U,
    paramForClick: U,
    paramForDblclick: U,
    funForMousedown: U,
    funForMouseup: U,
    funForClick: U,
    funForDblclick: U,
    invokeFun: function () {
        eventHandler.getEvent();
        switch (eventHandler.eventType) {
            case 0:
                if (!u(eventHandler.funForMousedown)) {
                    eventHandler.funForMousedown();
                }
                break;
            case 1:
                if (eventHandler.funForMouseup) {
                    eventHandler.funForMouseup();
                    eventHandler.funForMouseup = null;
                }
                break;
            case 2:
                if (eventHandler.funForClick) {
                    eventHandler.funForClick();
                    eventHandler.funForClick = null;
                }
                break;
            case 3:
                if (eventHandler.funForDblclick) {
                    eventHandler.funForDblclick();
                    eventHandler.funForDblclick = null;
                }
                break;
            case 4:
                break;
        }
    },
    fun_onmousemove: function () {
        g.mouseEvent = oneLayerClone(lib.formatEvent(arguments[0]));
        if (!u(g.WebActive) && g.WebActive.isLMousedown == 1) {
            eventHandler.g_eventArray.push(g.mouseEvent);
            setTimeout(eventHandler.setMoveToTrue, 1000);
            eventHandler.eventType = 4;
        }
    },
    setMoveToTrue: function () {
        g.WebActive.isLMousedown = 0;
    },
    fun_onmousedown: function () {
        g.mouseEvent = oneLayerClone(lib.formatEvent(arguments[0]));
        var trigger = g.mouseEvent.target;
        switch (trigger.getAttribute("eleFlag")) {
            case "webEle":
                break;
            default:
                break;
        }
        if (trigger.tagName == "TD") {
            specialEffect.m(trigger, lib.formatEvent(arguments[0]));
            return;
        }
        else {
        }
        eventHandler.g_eventArray.push(g.mouseEvent);
        setTimeout(eventHandler.invokeFun, 400);
        if (g.mouseEvent.Propagation) {
            g.mouseEvent.stopPropagation();
        }
        else {
            g.mouseEvent.cancelBubble = true;
        }
        if (g.mouseEvent.preventDefault) {
            g.mouseEvent.preventDefault();
        }
        else {
            g.mouseEvent.returnValue = false;
        }
    },
    fun_onmouseup: function () {
        g.mouseEvent = oneLayerClone(lib.formatEvent(arguments[0]));
        eventHandler.g_eventArray.push(g.mouseEvent);
    },
    fun_onclick: function () {
        var trigger = lib.formatEvent(arguments[0]).target;
        switch (trigger.getAttribute("eleFlag")) {
            case "webEle":
                eventHandler.funForClick = funForWebEleClick;
                break;
            case "CateNameEle":
                eventHandler.funForClick = funForCateEleClick;
                break;
            default:
                break;
        }
        g.mouseEvent = oneLayerClone(lib.formatEvent(arguments[0]));
        eventHandler.g_eventArray.push(g.mouseEvent);
    },
    fun_ondblclick: function () {
        switch (lib.formatEvent(arguments[0]).target.eleFlag) {
            case "CateNameEle":
                eventHandler.funForDblclick = funForCateEleDblclick;
                break;
            default:
                break;
        }
        g.mouseEvent = oneLayerClone(lib.formatEvent(arguments[0]));
        eventHandler.g_eventArray.push(g.mouseEvent);
    },
    reseteventType: function () {
        eventHandler.eventType = -1;
        eventHandler.g_eventArray.clear();
    },
    getEvent: function () {
        if (eventHandler.isMove == true) {
            eventHandler.isMove = false;
            eventHandler.eventType = -1;
            return;
        }
        if (eventHandler.g_eventArray.arr.length < 1) return;
        var firstTime = eventHandler.g_eventArray.arr[0].time;
        for (var i = 0; i < eventHandler.g_eventArray.arr.length && eventHandler.g_eventArray.arr[i].time > firstTime - 800; i++) {
            if (eventHandler.g_eventArray.arr[i].type == "dblclick") {
                eventHandler.eventType = 3;
                eventHandler.g_eventArray.clear();
                return;
            }
        }
        for (var i = 0; i < eventHandler.g_eventArray.arr.length && eventHandler.g_eventArray.arr[i].time > firstTime - 800; i++) {
            if (eventHandler.g_eventArray.arr[i].type == "click") {
                eventHandler.eventType = 2;
                eventHandler.g_eventArray.clear();
                return;
            }
        }
        for (var i = 0; i < eventHandler.g_eventArray.arr.length && eventHandler.g_eventArray.arr[i].time > firstTime - 800; i++) {
            if (eventHandler.g_eventArray.arr[i].type == "mousemove") {
                eventHandler.eventType = 4;
                eventHandler.g_eventArray.clear();
                return;
            }
        }
        if (eventHandler.g_eventArray.arr[0].type == "mouseup") {
            eventHandler.eventType = 1;
        }
        if (eventHandler.g_eventArray.arr[0].type == "mousedown") {
            eventHandler.eventType = 0;
        }
        eventHandler.g_eventArray.clear();
    },
    displayEventType: function () {
        eventHandler.getEvent();
        document.getElementById("result").innerHTML += "<br/>Event Type:" + eventHandler.eventType;
    }
}
var SpecialEffect = function () {
    var _ = this;
    _.placeElement = function (fromElement, preFromElement, elementContainer, eventType) {
        if (eventType == event.type) {
            g.elementDragClass.drag.ele.removeNode(true);
            if (elementContainer.clientLeft < event.x && event.x < elementContainer.clientLeft + elementContainer.clientWidth && elementContainer.clientTop < event.y && event.y < elementContainer.clientTop + elementContainer.clientHeight) {
                elementContainer.appendChild(g.elementDragClass.saved.ele);
                close(g.elementDragClass.source.ele);
            }
            else {
                g.elementDragClass.source.ele.style.cssText = g.elementDragClass.saved.ele.style.cssText;
            }
        }
    };
    _.m = function (p, e) {
        if (e.target.tagName != "TD") return;
        g.elementDragClass = new ThreeDomEleClass(p, p.cloneNode(true), p.cloneNode(true));
        if (u(g.elementDragClass) || u(g.elementDragClass.drag.ele)) return;
        g.tableRowWeb = getDataByMouse(e);
        if (u(g.tableRowWeb.rowData)) {
            return;
        }
        var dragTableDiv = $CE("DIV");
        var dragTable = g.tableRowWeb.tableData.Ele.cloneNode(false);
        dragTable.appendChild(g.elementDragClass.drag.ele);
        lib.dom.clearChildren(dragTableDiv);
        dragTableDiv.appendChild(dragTable);
        dragTableDiv.innerHTML = dragTableDiv.innerHTML;
        dragTableDiv.style.display = "inline";
        dragTableDiv.style.position = "absolute";
        var startX = findPos(p).absoluteLeft;
        var startY = e.clientY;
        var origY = g.elementDragClass.source.ele.offsetTop;
        var deltaY = startY - origY;
        iDiffX = e.clientX - g.tableRowWeb.rowData.RecLeft;
        iDiffY = e.clientY - g.tableRowWeb.rowData.RecTop;
        g.elementDragClass.source.ele.style.visibility = "hidden";
        if (dragTableDiv.style.left == "") {
            dragTableDiv.style.left = e.clientX - iDiffX + "px";
            dragTableDiv.style.top = e.clientY - iDiffY + "px";
        }
        g.elementDragClass.drag.ele = document.body.appendChild(dragTableDiv);
        if (document.addEventListener) {
            document.onmousemove = moveHandler;
            document.onmouseup = upHandler;
        }
        else if (document.attachEvent) {
            dragTableDiv.setCapture();
            dragTableDiv.onmousemove = moveHandler;
            dragTableDiv.onmouseup = upHandler;
            dragTableDiv.onlosecapture = upHandler;
        }
        else {
            var oldmovehandler = document.onmousemove;
            var olduphandler = document.onmouseup;
            document.onmousemove = moveHandler;
            document.onmouseup = upHandler;
        }
        function moveHandler(e) {
            if (!e) {
                e = lib.getEvent();
            }
            e = EventUtil.formatEvent(e);
            dragTableDiv.style.left = e.clientX - iDiffX + "px";
            dragTableDiv.style.top = e.clientY - iDiffY + "px";
            if (e.stopPropagation) e.stopPropagation();
            else e.cancelBubble = true;
        }
        function upHandler(e) {
            if (!e) e = lib.getEvent();
            var tmpIDs = g.elementDragClass.source.ele.getAttribute("relationalID").split("-");
            var tmpWebRow = g.page.$(tmpIDs[0]).$(tmpIDs[1]);
            tmpWebRow.funForLMouseUpAfterMoveWhileDown();
            if (document.removEventListener) {
                document.onmouseup = null;
                document.onmousemove = null;
                document.removeEventListener("mouseup", upHandler, true);
                document.removeEventListener("mousemove", moveHandler, true);
            }
            else if (document.detachEvent) {
                dragTableDiv.onlosecapture = null;
                dragTableDiv.onmouseup = null;
                dragTableDiv.onmousemove = null;
                dragTableDiv.releaseCapture();
            }
            else {
                document.onmouseup = olduphandler;
                document.onmousemove = oldmovehandler;
            }
            if (e.stopPropagation) e.stopPropagation();
            else e.cancelBubble = true;
        }
    };
}
var specialEffect = new SpecialEffect();
function ThreeDomEleClass(a, b, c) {
    var _ = this;
    _.source = { ele: a, parent: _ };
    _.saved = { ele: b, parent: _ };
    _.drag = { ele: c, parent: _ };
    _.empty = function () {
        if (U != _.source.ele) _.source.ele.outerHTML = "";
        if (U != _.saved.ele) _.saved.ele.outerHTML = "";
        if (U != _.drag.ele) _.drag.ele.outerHTML = "";
    }
}
function Region() {
    var _ = this;
    _.RecLeft = 0;
    _.RecTop = 0;
    _.RecRight = 0;
    _.RecBottom = 0;
    _.setRec = function (p, q, right, bottom) {
        _.RecLeft = p;
        _.RecTop = q;
        _.RecRight = right;
        _.RecBottom = bottom;
    };
    _.setRecByEle = function () {
        _.RecLeft = 0;
        _.RecTop = 0;
        _.RecRight = 0;
        _.RecBottom = 0;
        var t = _.Ele;
        if (t.offsetParent) {
            while (1) {
                _.RecLeft += t.offsetLeft;
                _.RecTop += t.offsetTop;
                if (!t.offsetParent) {
                    break;
                }
                t = t.offsetParent;
            }
        }
        else if (t.x && t.y) {
            _.RecLeft += t.x;
            _.RecTop += t.y;
        }
        _.RecRight = _.RecLeft + _.Ele.offsetWidth;
        _.RecBottom = _.RecTop + _.Ele.offsetHeight;
        return _;
    };
    _.r = function () {
        _.setRecByEle();
        var childEles = _.Webs || _.Categories || _.Tables;
        if (u(childEles)) {
            return _;
        }
        for (var i = 0; i < childEles.length; i++) {
            childEles[i].r();
        }
        return _;
    };
    _.isOver = function (x, y) {
        try {
            return (x > _.RecLeft && x < _.RecRight && y > _.RecTop && y < _.RecBottom) ? true : false;
        }
        catch (e) {
            return false;
        }
    };
    _.isOverEvent = function (p) {
        var t = EventUtil.formatEvent(p);
        return _.isOver(t.pageX, t.pageY);
    };
}
function message(from, to, owner, content, webTable) {
    this.from = from;
    this.to = to;
    this.owner = owner;
    this.content = content;
    this.webTable = webTable;
    this.isRead = 0;
}
function User(p, q, image) {
    var _ = this;
    _.username = p;
    _.email = q;
    _.image = image;
    _.messages = new Array;
    _.logOut = function () {
    };
    _.logIn = function () {
    };
    _.sendMessage = function () {
    };
    _.getMessage = function () {
    };
    _.setUserInfo = function () {
        if (!u(_.username)) {
            lib.cookie.set("username", _.username, 30, "/", true);
            $("userInfor").innerHTML = "你好," + _.username + "&nbsp<a href='javascript:void(0)' onclick='g.logout();' class='linkOne' style='color:Blue;'>注销</a>";
        }
        else {
            $("userInfor").innerHTML = "";
        }
    }
}
function EventForEle(p) {
    var _ = this;
    _.EleToEvent = p.Ele;
    _.isLDown = false;
    _.isRDown = false;
    _.isLMoveWhileDown = false;
    _.firRDownT = null;
    _.firRUpT = null;
    _.isDbClick = 0;
    _.firClickTime = null;
    _.secClickTime = null;
    _.firLDownClientX = 0;
    _.firLDownClientY = 0;
    _.firLDownT = null;
    _.firUpT = null;
    _.timeFunName = null;
    _.active_element;
    _.bIsMSIE;
    _.isLButton = function (e) {
        if (navigator.userAgent.indexOf("MSIE") > 0)
            return lib.getEvent().button == 1;
        else
            return lib.getEvent().button == 0;
    };
    _.isRButton = function () {
        if (navigator.userAgent.indexOf("MSIE"))
            return lib.getEvent().button == 2;
        else
            return lib.getEvent().button == 2;
    };
    _.EleToEvent.onmouseover = function () {
        return false;
    };
    _.EleToEvent.onmouseout = function () {
        return false;
    };
    _.funcAMouseOn = function () {
    };
    _.EleToEvent.onmousedown = function () {
        var e = lib.getEvent();
        if (_.isLButton(e)) {
            _.firLDownT = new Date();
            _.isLDown = true;
            _.firLDownClientX = e.clientX;
            _.firLDownClientY = e.clientY;
            _.funcAMouseOn(e);
        }
        else if (_.isRButton(lib.getEvent())) {
            _.isRDown = true;
            _.firRDownT = new Date();
        }
        return false;
    };
    _.EleToEvent.onmousemove = function () {
        funForOnmousemove(arguments);
        document.body.onmousemove = funForOnmousemove;
        return false;
    };
    _.funcBLeftMouseUp = function () {
        if (_.isLMoveWhileDown == true) {
            _.isLMoveWhileDown = false;
            p.funForLMouseUpAfterMoveWhileDown();
        }
        else {
            p.funForLMouseUp();
        }
        _.isFirstMousedownMove = false;
    };
    _.funcBRightClick = function () {
        p.funForRMouseClick();
    };
    _.EleToEvent.onmouseup = function () {
        if (_.isLButton(lib.getEvent())) {
            _.firUpT = new Date();
            if (_.isLDown) _.funcBLeftMouseUp();
            _.isLDown = false;
        }
        else if (_.isRButton(lib.getEvent())) {
            _.firRUpT = new Date();
            if (_.isRDown && (_.firRUpT.getTime() - _.firRDownT.getTime() < 200)) {
                _.funcBRightClick();
                _.isRDown = false;
            }
        }
        return false;
    };
    if (window.attachEvent) {
        _.active_element = document.activeElement;
        _.bIsMSIE = true;
        document.onfocusout = function () {
            if (_.bIsMSIE && (_.active_element != document.activeElement)) {
                _.active_element = document.activeElement;
            }
            else {
                if (_.isLDown) _.funcBLeftMouseUp();
                _.isLDown = false;
            }
        };
    }
    else {
        window.onblur = function () {
            if (_.isLDown) _.funcBLeftMouseUp();
            _.isLDown = false;
            return false;
        };
    }
    _.funcBLeftClick = function () {
        p.funForLMouseClick();
    };
    _.EleToEvent.onclick = function () {
        clearTimeout(_.timeFunName);
        _.timeFunName = setTimeout(function () {
            if (_.isDbClick == 0 && _.firUpT.getTime() - _.firLDownT.getTime() < 200)
                _.funcBLeftClick();
            _.isDbClick = 0;
        }, 300);
        return false;
    };
    _.funcBLeftDbClick = function () {
        p.funForLMouseDblclick();
    };
    _.EleToEvent.ondblclick = function () {
        _.isDbClick = 1;
        _.funcBLeftDbClick();
        return false;
    };
    function funForOnmousemove() {
        var e = lib.getEvent();
        var ele = e.srcElement;
        if (!u(g.dragEle) && ele != g.dragEle) {
            g.dragEle.style.left = (e.clientX - g.initialOffsetX) + "px";
            g.dragEle.style.top = (e.clientY - g.initialOffsetY) + "px";
        }
        if (_.isLDown) {
            _.isLMoveWhileDown = true;
            p.funForLMouseMoveWhileDown();
            if (_.isFirstMousedownMove == false) {
                _.isFirstMousedownMove = true;
                document.body.onmousemove = this;
            }
        }
        else {
            p.funForMouseMoveWithoutDown();
        }
    }
}
function Web(p, q, Link, Note, Cate, Cr, Key, Lans, tagName, parent) {
    Region.call(this);
    var _ = this;
    _.ID = p;
    _.Name = q;
    _.Link = Link;
    _.Note = Note;
    _.Cate = Cate;
    _.Cr = Cr;
    _.Key = Key;
    _.Lans = Lans;
    _.Ele = document.createDocumentFragment();
    _.EditEle = U;
    _.ShowDeleteEle = $CE("DIV");
    _.isSelected = false;
    _.isLMousedown = 0;
    _.ContainerFlag = 0;
    _.Parent = parent;
    _.isFirstMousedownMove = false;
    _.initialOffsetX = 0;
    _.initialOffsetY = 0;
    _.l = function () {
        return (new Web((new Date).getTime() + "Web", _.Name, _.Link, _.Note, _.Cate, _.Cr, _.Key, _.Lans, _.tagName, _.Parent)).c();
    };
    _.a = function (p) {
        var t = "{'action':'AddWeb','data':{'table':{'ID':'" + _.Parent.Parent.ID + "','row':{'ID':'" + _.Parent.ID + "','web':{'ID':'" + _.ID + "','Name':'" + _.Name + "','Link':'" + _.Link + "','Note':'" + _.Note + "'},'index':'" + p + "'}}}}";
        g_ComWithServer.add(g_domainURL + "/ResponseTest.aspx", t);
        g_ComWithServer.startSend();
    };
    _.b = function (p, q) {
        var t = "{'action':'CopyWeb','data':{'from': {'table':{'ID':'" + _.Parent.Parent.ID + "','row':{'ID':'" + _.Parent.ID + "','web':{'ID':'" + _.ID + "'}}}},'to':{'table':{'ID':'" + p.Parent.Parent.ID + "','row':{'ID':'" + p.Parent.ID + "','web':{'ID':'" + p.ID + "'}}}},'index':'" + q + "'}}";
        g_ComWithServer.add(g_domainURL + "/ResponseTest.aspx", t);
        g_ComWithServer.startSend();
    };
    _.f = function () {
        var t = "{'action':'DeleteWeb','data':{'table':{'ID':'" + _.Parent.Parent.ID + "','row':{'ID':'" + _.Parent.ID + "','web':{'ID':'" + _.ID + "'}}}}";
        g_ComWithServer.add(g_domainURL + "/ResponseTest.aspx", t);
        g_ComWithServer.startSend();
    }
    _.u = function () {
        var t = "{'action':'UpdateWeb','data':{'table':{'ID':'" + _.Parent.Parent.ID + "','row':{'ID':'" + _.Parent.ID + "','web':{'ID':'" + _.ID + "','Name':'" + _.Name + "','Link':'" + _.Link + "','Note':'" + _.Note + "'}}}}}";
        g_ComWithServer.add(g_domainURL + "/ResponseTest.aspx", t);
        g_ComWithServer.startSend();
    }
    _.v = function () {
        var t = "{'action':'CopyWeb','data':{'from': {'table':{'ID':'" + _.Parent.Parent.ID + "','row':{'ID':'" + _.Parent.ID + "','web':{'ID':'" + _.ID + "'}}}},'to':{'table':{'ID':'" + p.Parent.Parent.ID + "','row':{'ID':'" + p.Parent.ID + "}}},'index':'" + q + "'}}";
        g_ComWithServer.add(g_domainURL + "/ResponseTest.aspx", t);
        g_ComWithServer.startSend();
    }
    _.g = function () {
        var t = _.Parent;
        lib.dom.setStyle(t.delButton, "cursor:default;visibility:hidden;");
        for (var i = 0; i < t.Webs.length; i++) {
            if (t.Webs[i].ID == _.ID) {
                t.Webs.splice(i, 1);
                t.d();
                _.f();
                break;
            }
        }
    };
    _.h = function (p) {
        _.Name = p.Name;
        _.Link = p.Link;
        _.Note = p.Note;
        _.Cate = p.Cate;
        _.Cr = p.Cr;
        _.Key = p.Key;
        _.Lans = p.Lans;
        _.Ele.innerHTML = p.Name;
        $SA(_.Ele, "Link", p.Link);
        _.Ele.title = p.Note;
        _.Parent.r();
        _.u();
    }
    _.l = function () {
        return (new Web((new Date).getTime() + "Web", _.Name, _.Link, _.Note, _.Cate, _.Cr, _.Key, _.Lans, _.tagName, _.Parent)).c();
    };
    _.c = function () {
        _.Ele = $CE("A");
        $SA(_.Ele, "id", "webElement2010" + _.ID);
        $SA(_.Ele, "Link", _.Link);
        $SA(_.Ele, "Note", _.Note);
        $SA(_.Ele, "Cate", _.Cate);
        $SA(_.Ele, "eleFlag", "webEle");
        _.Ele.title = _.Note;
        lib.dom.setStyle(_.Ele, "background-Color:#ddeedd;margin-right:5px;cursor:default;"); ;
        _.Ele.innerHTML = _.Name;
        _.funForLMouseDown = function () { };
        _.funForLMouseUp = function () { };
        _.funForLMouseClick = function () {
            open(_.Link);
        };
        _.funForLMouseDblclick = function () {
            var t = new EditWeb(_);
        };
        _.funForLMouseMoveWhileDown = function () {
            var e = lib.getEvent();
            if (_.isFirstMousedownMove == false) {
                _.isFirstMousedownMove = true;
                g.initialOffsetX = _.initialOffsetX = e.clientX - _.RecLeft;
                g.initialOffsetY = _.initialOffsetY = e.clientY - _.RecTop;
                _.dragWeb = _.Ele.cloneNode(true);
                _.dragWeb.id = "drag" + _.ID;
                _.Ele.style.position = "absolute";
                _.Ele.parentNode.insertBefore(_.dragWeb, _.Ele);
                g.dragEle = _.Ele;
                g.elementDragClass = new ThreeDomEleClass(_.Ele, _.dragWeb, _.dragWeb);
            }
            _.Ele.style.left = (e.clientX - _.initialOffsetX) + "px";
            _.Ele.style.top = (e.clientY - _.initialOffsetY) + "px";
        };
        _.funForRMouseDown = function () { };
        _.funForRMouseUp = function () { };
        _.funForRMouseClick = function () { };
        _.funForRMouseDblclick = function () { };
        _.funForRMouseMoveWhileDown = function () { };
        _.funForMouseMoveWithoutDown = function () { };
        _.funForLMouseUpAfterMoveWhileDown = function () {
            document.onmousemove = null;
            _.isFirstMousedownMove = false;
            _.Ele.position = "";
            var index = -1;
            var t = $("drag" + _.ID);
            if (t != null) {
                lib.dom.setStyle(_.Ele, t.style.cssText);
                t.parentNode.removeChild(t);
            }
            var e = lib.getEvent();
            if (u(g.elementDragClass)) {
                return;
            }
            if (u(g.elementDragClass.drag)) {
                return;
            }
            if (g.elementDragClass.drag.ele.parentNode != null) {
                g.elementDragClass.drag.ele.parentNode.removeChild(g.elementDragClass.drag.ele);
            }
            g.tableRowWeb = getDataByMouse(e);
            _.Ele.style.visibility = "";
            if (!u(g.tableRowWeb.tableData) && !u(g.tableRowWeb.tableData.selectWeb)) {
                g.tableRowWeb.tableData.selectWeb.n();
                if (!u(g.tableRowWeb.tableData.selectWebRow)) {
                    g.tableRowWeb.tableData.selectWebRow.delButton.style.visibility = "hidden";
                }
            }
            if (!u(g.tableRowWeb.rowData))
                g.tableRowWeb.tableData.selectWebRow = g.tableRowWeb.rowData;
            if (!u(g.tableRowWeb.tableData)) {
                if (!u(g.tableRowWeb.rowData)) {
                    if (g.elementDragClass.source.ele.parentNode != null) {
                        g.elementDragClass.source.ele.parentNode.removeChild(g.elementDragClass.source.ele);
                    }
                    if (!u(g.tableRowWeb.webData)) {
                        g.tableRowWeb.webData.isLMousedown = 0;
                        g.selectedData.resume();
                        if (g.tableRowWeb.webData.ID != _.ID) {
                            index = lib.data.getOrder(g.tableRowWeb.rowData.Webs, g.tableRowWeb.webData);
                            g.tableRowWeb.rowData.o(_, index);
                            g.tableRowWeb.rowData.d();
                            g.tableRowWeb.rowData.r();
                            _.g();
                            _.Parent.d();
                            _.Parent.r();
                        }
                        else {
                            _.Parent.d();
                        }
                    }
                    else if (g.tableRowWeb.isFirst) {
                        if (g.tableRowWeb.rowData.Webs[0].ID == _.ID) {
                            index = 0;
                            g.tableRowWeb.rowData.o(_, 0);
                        }
                        else {
                        }
                    }
                    else {
                        var b = _.Parent;
                        var index = g.tableRowWeb.rowData.Webs.length;
                        var a = _.l();
                        g.tableRowWeb.rowData.Webs.push(a);
                        a.Parent = g.tableRowWeb.rowData;
                        _.b(a, index);
                        g.tableRowWeb.rowData.d();
                        g.tableRowWeb.rowData.r();
                        b.g(_);
                        b.d();
                        b.r();
                    }
                    if (g.tableRowWeb.rowData.ID != _.Parent.ID) {
                        _.n();
                        lib.dom.setStyle(_.Parent.delButton, "cursor:default;visibility:hidden;");
                    }
                    _.Parent = g.tableRowWeb.rowData;
                }
                else {
                }
            }
            else {
            }
            g.elementDragClass = U;
            if (u(_.Parent.lastOperateWeb)) {
                _.Parent.lastOperateWeb = _;
                _.m();
                lib.dom.setStyle(_.Parent.delButton, "cursor:default;");
            }
            else if (_.Parent.lastOperateWeb === _) {
                _.Parent.lastOperateWeb = U;
                _.n();
                lib.dom.setStyle(_.Parent.delButton, "cursor:default;visibility:hidden;");
            }
            else {
                _.Parent.lastOperateWeb.n();
                _.Parent.lastOperateWeb = _;
                _.m();
                lib.dom.setStyle(_.Parent.delButton, "cursor:default;");
            }
        };
        EventForEle.call(_, { "Ele": _.Ele, "funForLMouseDown": _.funForLMouseDown, "funForLMouseUp": _.funForLMouseUp, "funForLMouseClick": _.funForLMouseClick
, "funForLMouseDblclick": _.funForLMouseDblclick, "funForLMouseMoveWhileDown": _.funForLMouseMoveWhileDown
, "funForRMouseDown": _.funForRMouseDown, "funForRMouseUp": _.funForRMouseUp, "funForRMouseClick": _.funForRMouseClick
, "funForRMouseDblclick": _.funForRMouseDblclick, "funForRMouseMoveWhileDown": _.funForRMouseMoveWhileDown
, "funForMouseMoveWithoutDown": _.funForMouseMoveWithoutDown, "funForLMouseUpAfterMoveWhileDown": _.funForLMouseUpAfterMoveWhileDown
        });
        return _;
    };
    _.i = function () {
        _.Ele.innerHTML = _.Name;
        $SA(_.Ele, "Link", _.Link);
        $SA(_.Ele, "Note", _.Note);
        $SA(_.Ele, "Cate", _.Cate);
        $SA(_.Ele, "Cr", _.Cr);
    };
    _.j = function (p) {
        var t = {};
        if (p) {
            t.ID = lib.Time.getID() + "WEB";
        } else {
            t.ID = _.ID;
        }
        t.Name = _.Name;
        t.Link = _.Link;
        t.Note = _.Note;
        t.Cr = _.Cr;
        return t;
    };
    _.k = function () {
        if ($("deleteWeb" + _.ID))
            return;
        _.ShowDeleteEle = $CE("DIV");
        var tmpCsstext = "display:inline;background-color:#DDEEDD;borderStyle:solid;borderWidth:1px;borderColor:#5858FA;float:left;";
        lib.dom.setStyle(_.ShowDeleteEle, tmpCsstext);
        $SA(_.ShowDeleteEle, "id", "deleteWeb" + _.ID);
        _.ShowDeleteEle.innerHTML = "<span style='cursor:default;' ParentID='" + _.ID + "' onclick='webClose(this)'>x</span>";
        addEleAround(_.Ele, _.ShowDeleteEle, "topright");
    };
    _.m = function () {
        _.Ele.style.backgroundColor = "#B0E0E6";
    };
    _.n = function () {
        _.Ele.style.backgroundColor = "#DDEEDD";
    };
}
function WebRow(p, q, parent, webIDHTML, numDisFirst) {
    var _ = this;
    Region.call(_);
    _.ID = p;
    _.CateName = q;
    _.webIDHTML = webIDHTML;
    _.numDisFirst = numDisFirst;
    _.Ele = U;
    _.CateNameEle = U;
    _.addButton = $CE("A");
    _.delButton = $CE("A");
    _.delRowButton = $CE("A");
    _.leftArrow = $CE("A");
    _.rightArrow = $CE("A");
    _.editAndAddEle = $CE("DIV");
    _.editCateNameEle = U;
    _.lastOperateWeb = U;
    _.Parent = parent;
    _.initialOffsetX = 0;
    _.initialOffsetY = 0;
    _.isFirstMousedownMove = false;
    _.websIndex = new Array;
    _.Webs = new Array;
    _.dragTableDiv = {};
    _.lastDisWeb = {};
    _.closeEditor = function () {
        _.Webs.forEach(function (_p) {
            _p.closeEditor();
        });
    };
    _.l = function () {
        var t = new WebRow((new Date).getTime() + "CATE", _.CateName, _.parent, _.webIDHTML, _.numDisFirst);
        for (var i = 0; i < _.Webs.length; i++) {
            t.Webs.push(_.Webs[i].l());
        }
        return t;
    };
    _.a = function (p) {
        var t = "{'action':'AddRow','data':{'table':{'ID':'" + _.Parent.ID + "','row':{'ID':'" + _.ID + "','CateName':'" + _.CateName + "'},'index':'" + p + "'}}";
        g_ComWithServer.add(g_domainURL + "/ResponseTest.aspx", t);
        g_ComWithServer.startSend();
    }
    _.b = function (p, q) {
        var a = new Array;
        p.Webs.forEach(function (_web) {
            a.push("{'ID':'" + _web.ID + "'}");
        });
        var tmpRowData;
        if (p.Webs.length == 0) {
            b = "'row':{'ID':'" + p.ID + "'}";
        }
        else {
            b = "'row':{'ID':'" + p.ID + "','web':[" + a.join(',') + "]}";
        }
        var t = "{'action':'CopyRow','data':{'from': {'table':{'ID':'" + _.Parent.ID + "','row':{'ID':'" + _.ID + "'}}},'to':{'table':{'ID':'" + p.Parent.ID + "'," + b + "}},'index':'" + q + "'}}";
        g_ComWithServer.add(g_domainURL + "/ResponseTest.aspx", t);
        g_ComWithServer.startSend();
    };
    _.f = function () {
        var t = "{'action':'DeleteRow','data':{'table':{'ID':'" + _.Parent.ID + "','row':{'ID':'" + _.ID + "'}}}";
        g_ComWithServer.add(g_domainURL + "/ResponseTest.aspx", t);
        g_ComWithServer.startSend();
    };
    _.u = function () {
        var t = "{'action':'UpdateRow','data':{'table':{'ID':'" + _.Parent.ID + "','row':{'ID':'" + _.ID + "','CateName':'" + _.CateName + "'}}}";
        g_ComWithServer.add(g_domainURL + "/ResponseTest.aspx", t);
        g_ComWithServer.startSend();
    };
    _.v = function () {
    }
    _.o = function (p, q) {
        _.Webs.splice(q, 0, p);
        p.Parent = _;
        _.lastOperateWeb = p;
        _.Parent.lastOperateRow = _;
        p.a(q);
        if (lib.data.getOrder(_.Webs, p) > lib.data.getOrder(_.Webs, _.m())) {
            var a = lib.data.getOrder(_.Webs, p);
            var b = 0;
            for (var i = a; i >= 0; i--) {
                b = b + lib.data.getStrLength(_.Webs[i].Name) * 8 + 5;
                if (b > 600) {
                    _.numDisFirst = i + 1;
                    break;
                }
            }
        }
        var tmpDataToServerB = "{'action':'numDisFirst','data':{'table':{'ID':'" + _.Parent.ID + "','row':{'ID':'" + _.ID + "','numDisFirst':'" + _.numDisFirst + "'}}}}";
        g_ComWithServer.add(g_domainURL + "/ResponseTest.aspx", tmpDataToServerB);
        g_ComWithServer.startSend();
        _.Parent.Parent.d();
        _.Parent.Parent.r();
    };
    _.s = function (p) {
        if (u(p))
            return;
        if (__typeof__(p) === 'String') {
            p = eval('(' + p + ')');
        }
        var tmpWebs;
        if (u(p.Mrowwebs)) {
        }
        else {
            if (u(p.Mrowwebs.web.length)) {
                tmpWebs = new Array;
                tmpWebs.push(p.Mrowwebs.web);
            }
            else {
                tmpWebs = p.Mrowwebs.web;
            }
            for (var i = 0; i < tmpWebs.length; i++) {
                var tmpA = new Web(tmpWebs[i].ID,
tmpWebs[i].Name,
tmpWebs[i].Link,
tmpWebs[i].Note,
tmpWebs[i].Cate,
tmpWebs[i].Cr,
tmpWebs[i].Key,
tmpWebs[i].Lans,
"A",
_);
                _.Webs.push(tmpA);
            }
        }
    };
    _.g = function (p) {
        for (var i = 0; i < _.Webs.length; i++) {
            if (_.Webs[i] === p) {
                p.f();
                _.Webs.splice(i, 1);
                _.d();
                return;
            }
        }
    };
    _.h = function () {
        if (!u(_.lastOperateWeb)) {
            _.lastOperateWeb.g();
        }
    };
    _.c = function () {
        var a = $CE("td");
        a.id = _.ID;
        $SA(a, "relationalID", _.Parent.ID + "-" + _.ID);
        lib.dom.setStyle(a, "background-color:#F8F8F8;width:500px;height:20px;");
        _.CateNameEle = $CE("A");
        _.CateNameEle.innerHTML = _.CateName;
        $SA(_.CateNameEle, "Link", g_domainURL + "/" + _.CateName);
        $SA(_.CateNameEle, "ParentID", _.ID);
        $SA(_.CateNameEle, "eleFlag", "CateNameEle");
        lib.dom.setStyle(_.CateNameEle, "margin-right:5px;color:#874606;cursor:default;");
        a.appendChild(_.CateNameEle);
        _.leftArrow.innerHTML = "<-";
        $SA(_.leftArrow, "id", "lfArrow" + _.ID);
        $SA(_.leftArrow, "ParentID", _.ID);
        $SA(_.leftArrow, "title", "previous links");
        _.leftArrow.onclick = function () {
            var b = 0;
            for (var i = _.numDisFirst - 1; i > 0; i--) {
                if (u(_.Webs[i].Name)) alert("22");
                b = b + lib.data.getStrLength(_.Webs[i].Name) * 8 + 5;
                if (b > 600) {
                    _.numDisFirst = i + 1;
                    break;
                }
                _.numDisFirst = 0;
            }
            var t = "{'action':'numDisFirst','data':{'table':{'ID':'" + _.Parent.ID + "','row':{'ID':'" + _.ID + "','numDisFirst':'" + _.numDisFirst + "'}}}}";
            g_ComWithServer.add(g_domainURL + "/ResponseTest.aspx", t);
            g_ComWithServer.startSend();
            _.d();
            _.r();
        };
        lib.dom.setStyle(_.leftArrow, "cursor:default;");
        a.appendChild(_.leftArrow);
        var b = 0;
        for (var i = 0; i < _.Webs.length; i++) {
            if (i < _.numDisFirst) {
            }
            else {
                var c = _.Webs[i];
                if (u(c.Name)) continue;
                if (b + lib.data.getStrLength(c.Name) * 8 + 5 < 600) {
                    if (u(c.Name)) alert("");
                    b = b + lib.data.getStrLength(c.Name) * 8 + 5;
                    c.Parent = _;
                    a.appendChild(c.c().Ele);
                    _.lastDisWeb = c;
                }
            }
        }
        _.rightArrow.innerHTML = "->";
        $SA(_.rightArrow, "id", "rtArrow" + _.ID);
        $SA(_.rightArrow, "ParentID", _.ID);
        $SA(_.rightArrow, "title", "next links");
        _.rightArrow.onclick = function () {
            var tmpIndex = lib.data.getOrder(_.Webs, _.lastDisWeb);
            if (tmpIndex < _.Webs.length - 1) {
                _.numDisFirst = tmpIndex + 1;
                var t = "{'action':'numDisFirst','data':{'table':{'ID':'" + _.Parent.ID + "','row':{'ID':'" + _.ID + "','numDisFirst':'" + _.numDisFirst + "'}}}}";
                g_ComWithServer.add(g_domainURL + "/ResponseTest.aspx", t);
                g_ComWithServer.startSend();
                _.d();
                _.r();
            }
            else {
                return;
            }
        };
        lib.dom.setStyle(_.rightArrow, "cursor:default;");
        a.appendChild(_.rightArrow);
        _.addButton.innerHTML = "+";
        $SA(_.addButton, "id", "add" + _.ID);
        $SA(_.addButton, "ParentID", _.ID);
        $SA(_.addButton, "relationalID", _.Parent.ID + "-" + _.ID);
        $SA(_.addButton, "title", "Add a link");
        _.addButton.onclick = addWeb;
        lib.dom.setStyle(_.addButton, "cursor:default;");
        a.appendChild(_.addButton);
        _.delButton.innerHTML = "x";
        $SA(_.delButton, "id", "delete" + _.ID);
        $SA(_.addButton, "ParentID", _.ID);
        $SA(_.delButton, "title", "Delete a link");
        _.delButton.onclick = function () {
            _.h();
            lib.dom.setStyle(_.delButton, "cursor:default;visibility:hidden;");
        };
        lib.dom.setStyle(_.delButton, "cursor:default;visibility:hidden;");
        a.appendChild(_.delButton);
        _.delRowButton.innerHTML = "X";
        $SA(_.delRowButton, "id", "deleteRow" + _.ID);
        $SA(_.delRowButton, "relationalID", _.Parent.ID + "-" + _.ID);
        $SA(_.delRowButton, "title", "Delete _ row");
        _.delRowButton.onclick = deleteRow;
        lib.dom.setStyle(_.delRowButton, "cursor:default;float:right;");
        a.appendChild(_.delRowButton);
        lib.dom.clearChildren(_.Ele);
        _.Ele = $CE("TR");
        _.Ele.appendChild(a);
        _.Ele.onmousedown = eventHandler.fun_onmousedown;
        $SA(_.Ele, "id", _.ID);
        $SA(_.Ele, "ParentID", _.Parent.ID);
        _.funForLMouseDown = function () { };
        _.funForLMouseUp = function () { };
        _.funForLMouseClick = function () {
            open("urlredirect.aspx?url=" + _.CateNameEle.getAttribute("Link"));
        };
        _.funForLMouseDblclick = function () {
            if (U != _.editCateNameEle && U != _.editCateNameEle.parentNode) {
                t.editCateNameEle.parentNode.removeChild(t.editCateNameEle);
            }
            _.editCateNameEle = $CE("DIV");
            _.editCateNameEle.innerHTML = "<input type='text' value='" + _.CateName + "' size='" + (_.CateName.length + 1) + "' onkeydown='closeCateNameEditor(this)'/><span style='cursor:default;' onclick='closeCateNameEditor(this)'>X</span>";
            $SA(_.editCateNameEle, "relationalID", _.Parent.ID + "-" + _.ID);
            $SA(_.editCateNameEle, "style", "display:inline;background-color:#DDEEDD;borderStyle:solid;borderWidth:1px;borderColor:#5858FA;float:left;");
            var tmpEle = _.Ele.getElementsByTagName("TD")[0];
            _.editCateNameEle = tmpEle.insertBefore(_.editCateNameEle, tmpEle.firstChild);
            _.CateNameEle.style.visibility = "hidden";
        };
        _.funForLMouseMoveWhileDown = function () {
            var e = lib.getEvent();
            if (_.isFirstMousedownMove == false) {
                _.isFirstMousedownMove = true;
                g.initialOffsetX = _.initialOffsetX = e.clientX - _.RecLeft;
                g.initialOffsetY = _.initialOffsetY = e.clientY - _.RecTop;
                _.ornamentalRow = _.Ele.cloneNode(true);
                _.ornamentalRow.id = "drag" + _.ID;
                _.Ele.style.position = "absolute";
                _.Ele.parentNode.insertBefore(_.ornamentalRow, _.Ele);
                g.dragEle = _.ornamentalRow;
                g.elementDragClass = new ThreeDomEleClass(_.Ele, _.ornamentalRow, _.oranmentalRow);
            }
            _.Ele.style.left = (e.clientX - _.initialOffsetX) + "px";
            _.Ele.style.top = (e.clientY - _.initialOffsetY) + "px";
        };
        _.funForRMouseDown = function () { };
        _.funForRMouseUp = function () { };
        _.funForRMouseClick = function () { };
        _.funForRMouseDblclick = function () { };
        _.funForRMouseMoveWhileDown = function () { };
        _.funForMouseMoveWithoutDown = function () {
        };
        _.funForLMouseUpAfterMoveWhileDown = function () {
            document.onmousemove = null;
            document.onmouseup = null;
            document.onlosecapture = null;
            g.dragEle = U;
            g.initialOffsetX = 0;
            g.initialOffsetY = 0;
            var e = lib.formatEvent(lib.getEvent());
            _.isFirstMousedownMove = false;
            _.Ele.style.position = "";
            var stillData = getDataByMouse(e);
            var webRowE = stillData.rowData;
            if (!u(webRowE)) {
                var tmpCates = webRowE.Parent.Categories;
                var k = lib.data.getOrder(tmpCates, webRowE);
                var i = lib.data.getOrder(_.Parent.Categories, _);
                var stillRowMiddleX = (_.RecLeft + _.RecRight) / 2;
                var dragRowMiddleX = findPos(g.elementDragClass.drag.ele).absoluteLeft + g.elementDragClass.drag.ele.clientWidth / 2;
                var t = 0;
                if ((findPos(g.elementDragClass.drag.ele).absoluteTop + g.elementDragClass.drag.ele.clientHeight / 2) > ((_.RecTop + _.RecBottom) / 2)) {
                    t++;
                }
                else {
                }
                var a = k + t;
                var b = _.l();
                b.Parent = stillData.tableData;
                _.b(b, a);
                _.f();
                stillData.tableData.Categories.splice(a, 0, b);
                if (k + t < i) {
                    i++;
                }
                _.Parent.Categories.splice(i, 1);
                _.Parent.d();
                _.Parent.Parent.d();
                _.Parent.Parent.r();
            }
            else {
            }
            g.elementDragClass.source.ele.style.visibility = "";
            g.elementDragClass.drag.ele.parentNode.removeChild(g.elementDragClass.drag.ele);
            g.elementDragClass = U;
            document.onmousemove = null;
        };
        EventForEle.call(_, { "Ele": _.CateNameEle, "funForLMouseDown": _.funForLMouseDown, "funForLMouseUp": _.funForLMouseUp, "funForLMouseClick": _.funForLMouseClick
, "funForLMouseDblclick": _.funForLMouseDblclick, "funForLMouseMoveWhileDown": _.funForLMouseMoveWhileDown
, "funForRMouseDown": _.funForRMouseDown, "funForRMouseUp": _.funForRMouseUp, "funForRMouseClick": _.funForRMouseClick
, "funForRMouseDblclick": _.funForRMouseDblclick, "funForRMouseMoveWhileDown": _.funForRMouseMoveWhileDown
, "funForMouseMoveWithoutDown": _.funForMouseMoveWithoutDown, "funForLMouseUpAfterMoveWhileDown": _.funForLMouseUpAfterMoveWhileDown
        });
        return _;
    };
    _.n = function () {
        lib.dom.clearChildren(_.editAndAddEle);
        lib.dom.setStyle(_.editAndAddEle, "position:absolute;z-index:5;background-color:#F2F2F2;border:solid;border-width:1px;border-color:#5858FA;");
        $SA(_.editAndAddEle, "id", "editAndAddWeb" + _.ID);
        var a = document.createTextNode("Name:");
        var b = $CE("INPUT");
        $SA(b, "id", "name_editAndAddWeb" + _.ID);
        $SA(b, "onfocus", 'resumeStyle(this)');
        b.type = "text";
        _.editAndAddEle.appendChild(a);
        _.editAndAddEle.appendChild(b);
        var a = document.createTextNode("Link:");
        var b = $CE("INPUT");
        $SA(b, "id", "link_editAndAddWeb" + _.ID);
        $SA(b, "onfocus", 'resumeStyle(this)');
        b.type = "text";
        _.editAndAddEle.appendChild(a);
        _.editAndAddEle.appendChild(b);
        var a = document.createTextNode("Note:");
        var b = $CE("INPUT");
        $SA(b, "id", "category_editAndAddWeb" + _.ID)
        $SA(b, "onfocus", 'resumeStyle(this)');
        b.type = "text";
        _.editAndAddEle.appendChild(a);
        _.editAndAddEle.appendChild(b);
        _.editAndAddEle.innerHTML += "<input type='button' relationalID='" + _.Parent.ID + "-" + _.ID + "' value='Save' onclick='addWebAndClose(this)'/>";
        _.editAndAddEle.innerHTML += "<span style='cursor:default;' relationalID='" + _.Parent.ID + "-" + _.ID + "' onclick='webClose(this)'>X</span>";
        _.editAndAddEle = document.body.appendChild(_.editAndAddEle);
        _.editAndAddEle.style.left = _.RecLeft + "px";
        _.editAndAddEle.style.top = (_.RecTop - _.editAndAddEle.offsetHeight) + "px";
    };
    _.$ = function (p) {
        for (var i = 0; i < _.Webs.length; i++) {
            if (p == _.Webs[i].ID) {
                return _.Webs[i];
            }
        }
    }
    _.m = function () {
        var t = 0;
        for (var i = _.numDisFirst; i < _.Webs.length; i++) {
            var tmpWeb = _.Webs[i];
            t = t + lib.data.getStrLength(tmpWeb.Name) * 8 + 5;
            if (t > 600) {
                return _.Webs[i - 1];
            }
        }
        return _.Webs[_.Webs.length - 1];
    };
    _.j = function (p) {
        var t = {};
        if (p) {
            t.Id = lib.Time.getID() + "CATE";
        } else {
            t.Id = _.ID;
        }
        t.Ct = _.CateName;
        t.NumDisFirst = _.NumDisFirst;
        t.Mrowwebs = {};
        t.Mrowwebs.web = new Array;
        _.Webs.forEach(function (_paraWeb) {
            t.Mrowwebs.web.push(_paraWeb.j(_isNewID));
        });
        return t;
    };
    _.d = function () {
        var t = _.Ele.getElementsByTagName("TD")[0];
        if (t.hasChildNodes()) {
            while (t.childNodes.length >= 1) {
                t.removeChild(t.firstChild);
            }
        }
        _.CateNameEle.style.visibility = "";
        t.appendChild(_.CateNameEle);
        t.appendChild(_.leftArrow);
        var a = 0;
        for (var i = 0; i < _.Webs.length; i++) {
            if (i < _.numDisFirst) {
            }
            else {
                var b = _.Webs[i];
                if (a + lib.data.getStrLength(b.Name) * 8 + 5 < 600) {
                    a = a + lib.data.getStrLength(b.Name) * 8 + 5;
                    b.c();
                    t.appendChild(b.Ele);
                    _.lastDisWeb = b;
                }
            }
        }
        t.appendChild(_.rightArrow);
        t.appendChild(_.addButton);
        t.appendChild(_.delButton);
        t.appendChild(_.delRowButton);
    };
    _.funForCateEleClick = function () {
        window.force.open("urlredirect.aspx?url=" + g.mouseEvent.target.getAttribute("Link"), '', '');
    };
    _.funForCateEleDblclick = function () {
        var t = getWebRowByID(g.mouseEvent.target.getAttribute("ParentID"));
        if (!u(t.editCateNameEle) && !u(t.editCateNameEle.parentNode)) {
            t.editCateNameEle.parentNode.removeChild(t.editCateNameEle);
        }
        t.editCateNameEle = $CE("DIV");
        t.editCateNameEle.innerHTML = "<input type='text' value='" + t.CateName + "' size='" + t.CateName.length + "'/><span style='cursor:default;' onclick='closeCateNameEditor(this)'>X</span>";
        $SA(t.editCateNameEle, "ParentID", t.ID);
        $SA(t.editCateNameEle, "style", "display:inline;background-color:#DDEEDD;borderStyle:solid;borderWidth:1px;borderColor:#5858FA;float:left;");
        t.editCateNameEle = tmpEle.insertBefore(t.editCateNameEle, t.Ele.getElementsByTagName("TD")[0].firstChild);
        t.CateNameEle.style.visibility = "hidden";
    };
}
function WebTable(p, q, containerEle, Parent) {
    var _ = this;
    Region.call(_);
    _.ID = p;
    _.Name = q;
    _.Parent = Parent;
    _.Categories = new Array();
    _.outerHTML = undefined;
    _.Ele = document.createDocumentFragment();
    _.Container = containerEle;
    _.titleEle = $CE("A");
    _.editTableTitleEle = undefined;
    _.delTableButton = $CE("A");
    _.headEle = undefined;
    _.TBodyEle = undefined;
    _.selectWeb = undefined;
    _.selectWebRow = undefined;
    _.lastOperateRow = undefined;
    _.inicialOffsetX = {};
    _.inicialOffsetY = {};
    _.isFirstMousedownMove = false;
    _.l = function () {
        var t = new WebTable((new Date).getTime() + "TB", _.Name, _.Container, _.Parent);
        for (var i = 0; i < _.Categories.length; i++) {
            t.Categories.push(_.Categories[i].l());
        }
        return t;
    };
    _.b = function (p, q) {
        var a = new Array;
        var t = "";
        var a = new Array;
        p.Categories.forEach(function (_row) {
            var c = new Array;
            _row.Webs.forEach(function (_web) {
                c.push("{'ID':'" + _web.ID + "'}");
            });
            t = "{'ID':'" + _row.ID + "','web':[" + c.join(",") + "]}";
            a.push(t);
        });
        var t = "{'action':'CopyTable','data':{'from':{'table':{'ID':'" + _.ID + "'}},'to':{'table':{'ID':'" + p.ID + "','row':[" + a.join(",") + "]}},'index':'" + q + "'}}";
        g_ComWithServer.add(g_domainURL + "/ResponseTest.aspx", t);
        g_ComWithServer.startSend();
    };
    _.a = function (p) {
        var t = "{'action':'AddTable','data':{'table':{'ID':'" + _.ID + "','Name':'" + _.Name + "'},'index':'" + p + "'}}";
        g_ComWithServer.add(g_domainURL + "/ResponseTest.aspx", t);
        g_ComWithServer.startSend();
    };
    _.f = function () {
        var t = "{'action':'DeleteTable','data':{'table':{'ID':'" + _.ID + "'}}}";
        g_ComWithServer.add(g_domainURL + "/ResponseTest.aspx", t);
        g_ComWithServer.startSend();
    };
    _.u = function () {
        var t = "{'action':'UpdateTable','data':{'table':{'ID':'" + _.ID + "','Name':'" + _.Name + "'}}}";
        g_ComWithServer.add(g_domainURL + "/ResponseTest.aspx", t);
        g_ComWithServer.startSend();
    };
    _.g = function () {
        var i = lib.data.getOrder(_.Parent.Tables, _);
        _.f();
        _.Parent.Tables.splice(i, 1);
        _.Parent.d();
        _.Parent.r();
    };
    _.c = function () {
        _.Ele = $CE("table");
        lib.dom.setStyle(_.Ele, "width:700px;");
        if (! +"\v1") {
            this.TBodyEle = $CE("TBODY");
        }
        tmpTr = $CE("TR");
        _.headEle = tmpTd = $CE("TD");
        tmpTr.appendChild(tmpTd);
        _.delTableButton.innerHTML = "X";
        $SA(_.delTableButton, "id", "deleteTable" + _.ID);
        $SA(_.delTableButton, "ParentID", _.ID);
        $SA(_.delTableButton, "title", "Delete this table");
        _.delTableButton.onclick = _.g;
        lib.dom.setStyle(_.delTableButton, "cursor:default;float:right;");
        _.titleEle.innerHTML = u(_.Name) ? "." : _.Name;
        _.titleEle.ondblclick = _.h;
        _.headEle.appendChild(_.titleEle);
        _.headEle.appendChild(_.delTableButton);
        _.headEle.style.backgroundColor = "#668822";
        _.m().appendChild(tmpTr);
        for (var i = 0; i < _.Categories.length; i++) {
            _.Categories[i].Parent = _;
            _.m().appendChild(_.Categories[i].c().Ele);
        }
        tmpTr = $CE("TR");
        tmpTd = $CE("TD");
        tmpTd.innerHTML = "<a title='Add a table' relationalID='" + _.ID + "' style='cursor:default;background-color:#88AA44;' onclick='editAddTable(this);'>Add table</a>" + "<a title='Add a category' relationalID='" + _.ID + "' style='cursor:default;float:right;background-color:#DDDDEE;' onclick='editAddCategory(this);'>+</a>";
        tmpTr.appendChild(tmpTd);
        _.m().appendChild(tmpTr);
        if (! +"\v1") {
            _.Ele.appendChild(_.TBodyEle);
        }
        _.funForLMouseDown = function () {
        };
        _.funForLMouseUp = function () {
        };
        _.funForLMouseClick = function () {
        };
        _.funForLMouseDblclick = function () { };
        _.funForLMouseMoveWhileDown = function () {
            e = lib.getEvent();
            if (_.isFirstMousedownMove == false) {
                _.inicialOffsetX = e.clientX - _.RecLeft;
                _.inicialOffsetY = e.clientY - _.RecTop;
                var t = _.Ele.cloneNode(true);
                var tmpNextEle = _.Ele.nextSibling;
                if (u(tmpNextEle)) {
                    _.Container.appendChild(t);
                }
                else {
                    _.Container.insertBefore(t, tmpNextEle);
                }
                t.id = "drag" + _.ID;
                t.style.visibility = "hidden";
                _.Ele.style.position = "absolute";
            }
            _.Ele.style.left = e.clientX - _.inicialOffsetX + "px";
            _.Ele.style.top = e.clientY - _.inicialOffsetY + "px";
        };
        _.funForRMouseDown = function () { };
        _.funForRMouseUp = function () { };
        _.funForRMouseClick = function () { };
        _.funForRMouseDblclick = function () { };
        _.funForRMouseMoveWhileDown = function () { };
        _.funForMouseMoveWithoutDown = function () { };
        _.funForLMouseUpAfterMoveWhileDown = function () {
            var a = (findPos(_.Ele).absoluteTop + _.Ele.clientHeight / 2);
            e = lib.getEvent();
            g.tableRowWeb = getDataByMouse(e);
            var t = $("drag" + _.ID);
            t.parentNode.removeChild(t);
            _.Ele.style.position = "";
            if (!u(g.tableRowWeb.tableData)) {
                if (g.tableRowWeb.tableData.ID != _.ID) {
                    var k = lib.data.getOrder(g.tableRowWeb.tableData.Parent.Tables, g.tableRowWeb.tableData);
                    var i = lib.data.getOrder(_.Parent.Tables, _);
                    var tmpAdd = 0;
                    var b = ((_.RecTop + _.RecBottom) / 2);
                    if (a > b) {
                        tmpAdd++;
                    }
                    else {
                    }
                    var tmpIndex = k + tmpAdd;
                    var cloneTable = _.l();
                    cloneTable.Parent = g.tableRowWeb.tableData.Parent;
                    _.Parent.Tables.splice(tmpIndex, 0, cloneTable);
                    _.b(cloneTable, tmpIndex);
                    _.f();
                    var tmp = _.Parent;
                    _.Parent = g.tableRowWeb.tableData.Parent;
                    if (k + tmpAdd < i) {
                        i++;
                    }
                    tmp.Tables.splice(i, 1);
                    _.Parent.d();
                    _.r();
                    g.tableRowWeb.tableData.Parent.d();
                    g.tableRowWeb.tableData.Parent.r();
                }
            }
        };
        EventForEle.call(_, { "Ele": _.headEle, "funForLMouseDown": _.funForLMouseDown, "funForLMouseUp": _.funForLMouseUp, "funForLMouseClick": _.funForLMouseClick
, "funForLMouseDblclick": _.funForLMouseDblclick, "funForLMouseMoveWhileDown": _.funForLMouseMoveWhileDown
, "funForRMouseDown": _.funForRMouseDown, "funForRMouseUp": _.funForRMouseUp, "funForRMouseClick": _.funForRMouseClick
, "funForRMouseDblclick": _.funForRMouseDblclick, "funForRMouseMoveWhileDown": _.funForRMouseMoveWhileDown
, "funForMouseMoveWithoutDown": _.funForMouseMoveWithoutDown, "funForLMouseUpAfterMoveWhileDown": _.funForLMouseUpAfterMoveWhileDown
        });
        return _;
    };
    _.h = function () {
        _.editTableTitleEle = $CE("DIV");
        _.editTableTitleEle.innerHTML = "<input type='text' value='" + (_.Name || ".") + "' size='" + (u(_.Name) ? 5 : (_.Name.length + 1)) + "' onmousemove='javascript:e = lib.getEvent();e = EventUtil.formatEvent(e);if (e.stopPropagation) e.stopPropagation();else e.cancelBubble = true;return false;' onkeydown='closeTableTitleEditor(this)'/><span style='cursor:default;' onclick='closeTableTitleEditor(this)'>X</span>";
        $SA(_.editTableTitleEle, "ParentID", _.ID);
        $SA(_.editTableTitleEle, "style", "display:inline;background-color:#DDEEDD;borderStyle:solid;borderWidth:1px;borderColor:#5858FA;float:left;");
        var tmpEle = _.Ele.getElementsByTagName("TD")[0];
        _.editTableTitleEle = tmpEle.insertBefore(_.editTableTitleEle, tmpEle.firstChild);
        _.titleEle.style.visibility = "hidden";
    };
    _.j = function (p) {
        var tmpData = {};
        tmpData.page = {};
        if (p) {
            tmpData.page.Id = lib.Time.getID() + "TABLE";
        } else {
            tmpData.page.Id = _.ID;
        }
        tmpData.page.Mrows = {};
        tmpData.page.Mrows.row = new Array;
        _.Categories.forEach(function (_paraCate) {
            tmpData.page.Mrows.row.push(_paraCate.j(p));
        });
        return tmpData;
    };
    _.m = function () {
        if (! +"\v1") {
            return _.TBodyEle;
        }
        else {
            return _.Ele;
        }
    };
    _.d = function () {
        var tmp = _.Container;
        if (!u(tmp)) {
            var index = lib.data.getOrder(_.Parent.Tables, _);
            _.Container.removeChild(_.Ele);
            var ele = _.c().Ele;
            if (u(_.Container.children) || index == _.Container.children.length) {
                _.Container.appendChild(ele);
            }
            else {
                _.Container.insertBefore(ele, _.Container.children[index]);
            }
        }
        return _;
    };
    _.$ = function (p) {
        for (var i = 0; i < _.Categories.length; i++) {
            if (p == _.Categories[i].ID) {
                return _.Categories[i];
            }
        }
    };
    _.s = function (p) {
        if (u(p))
            return;
        if (__typeof__(p) === 'String') {
            p = eval('(' + p + ')');
        }
        if (u(p.Mrows)) {
            return;
        }
        var t = p.Mrows.row;
        if (u(t.length)) {
            t = new Array;
            t.push(p.Mrows.row);
        }
        for (var i = 0; i < t.length; i++) {
            var tmpA = new WebRow(t[i].Id, t[i].Ct, _, "", t[i].NumDisFirst);
            _.Categories.push(tmpA);
            tmpA.s(t[i]);
        }
    };
}
function Page() {
    var _ = this;
    Region.call(_);
    _.Tables = new Array;
    _.Ele = _.Container = $("tdA");
    _.addTable = function () {
    };
    _.l = function () {
        var t = new Page();
        for (var i = 0; i < _.Tables.length; i++) {
            t.Tables.push(_.Tables[i].l());
        }
        return t;
    };
    _.s = function (p) {
        if (u(p))
            return;
        if (__typeof__(p) === 'String') {
            p = eval('(' + p + ')');
        }
        _.ID = p.page.Id;
        var t = p.page.Mtables.table;
        if (u(t.length)) {
            t = new Array;
            t.push(p.page.Mtables.table);
        }
        for (var i = 0; i < t.length; i++) {
            var a = new WebTable(t[i].Id, t[i].Name, $("tdA"), _);
            _.Tables.push(a);
            a.s(t[i]);
        }
    };
    _.c = function () {
        for (var i = 0; i < _.Tables.length; i++) {
            _.Ele.appendChild(_.Tables[i].c().Ele);
        }
        return _;
    };
    _.d = function () {
        var t = _.Container;
        if (!u(t)) {
            while (t.childNodes.length >= 1) {
                t.removeChild(t.firstChild);
            }
            for (var i = 0; i < _.Tables.length; i++) {
                var ele = _.Tables[i].c().Ele;
                _.Container.appendChild(ele);
            }
            return _;
        }
    };
    _.$ = function (p) {
        for (var i = 0; i < _.Tables.length; i++) {
            if (p == _.Tables[i].ID) {
                return _.Tables[i];
            }
        }
    };
}
function getWebFromTablesByID(id, webTables) {
    for (var k in webTables) {
        if (__typeof__(k) == "WebTable") {
            for (var i = 0; i < webTables[k].Categories.length; i++) {
                var tmpCate = webTables[k].Categories[i];
                for (var j = 0; j < tmpCate.Webs.length; j++) {
                    if (tmpCate.Webs[j].ID == id) {
                        return tmpCate.Webs[j];
                    }
                }
            }
        }
    }
}
function getWebByIDWithPre(id, _webTable) {
    var preString = "webElement2010";
    id = id.substring(preString.length, id.length);
    return getWebByID(id, _webTable);
}
function getWebByMose(e) {
    for (var k in g.WebTable) {
        for (var i = 0; i < g.WebTable[k].Categories.length; i++) {
            for (var j = 0, tmpCate = g.WebTable["First"].Categories[i]; j < tmpCate.Webs.length; j++) {
                var tmpWeb = tmpCate.Webs[j];
                if (tmpWeb.ID == g.elementDragClass.source.ele.getAttribute("ID") && tmpWeb.isOver(e.pageX, e.pageY)) {
                    return tmpWeb;
                }
            }
        }
    }
}
function getDataByMouse(e) {
    var tableData = U;
    var rowData = U;
    var webData = U;
    var isFirst = U;
    var tmpTables = g.page.Tables;
    for (var i in tmpTables) {
        if (tmpTables[i].isOverEvent && tmpTables[i].isOverEvent(e)) {
            tableData = tmpTables[i];
            for (var j = 0; j < tableData.Categories.length; j++) {
                if (tableData.Categories[j].isOverEvent(e)) {
                    rowData = tableData.Categories[j];
                    for (var k = 0; k < rowData.Webs.length; k++) {
                        if (rowData.Webs[k].isOverEvent(e)) {
                            webData = rowData.Webs[k];
                            break;
                        }
                    }
                    if (rowData.Webs.length > 0 && e.clientX < rowData.Webs[0].RecLeft) {
                        isFirst = true;
                    }
                    break;
                }
            }
            break;
        }
    }
    return { "tableData": tableData, "rowData": rowData, "webData": webData, "isFirst": isFirst };
}
function editAddCategory(value) {
    var editAddRowEle = $CE("DIV");
    $SA(editAddRowEle, "relationalID", value.getAttribute("relationalID"));
    editAddRowEle.style.position = "absolute";
    editAddRowEle.style.backgroundColor = "#F2F2F2";
    editAddRowEle.style.borderStyle = "solid";
    editAddRowEle.style.borderWidth = "1px";
    editAddRowEle.style.borderColor = "#5858FA";
    editAddRowEle.innerHTML = "类别<input type='text' onfocus='resumeStyle(this)' onkeydown='addCategory(this)'/><input type='button' value='Save' onclick='addCategory(this)'/><span style='cursor:default;' onclick='closeWindow(this.parentNode);'>X</span>";
    addEleAround(value, editAddRowEle, "rightbottom");
}
function addCategory(value) {
    var tmpEve = lib.getEvent();
    if (tmpEve.keyCode == 13 || value.type != "text") {
        var tmpNameObj = value.parentNode.getElementsByTagName("INPUT")[0];
        if (validateInput(tmpNameObj, /^\s*$/g) == false) {
            return;
        }
        var cateName = tmpNameObj.value;
        var newRow = new WebRow((new Date).getTime() + "CATE", cateName, g.page.$(value.parentNode.getAttribute("relationalID")), "");
        newRow.Parent.Categories.push(newRow);
        newRow.Parent.Parent.d();
        newRow.Parent.Parent.r();
        close(value.parentNode);
        newRow.Parent.lastOperateRow = newRow;
        newRow.a(newRow.Parent.Categories.length);
    }
}
function editAddTable(value) {
    var t = $CE("DIV");
    $SA(t, "relationalID", value.getAttribute("relationalID"));
    t.style.position = "absolute";
    t.style.backgroundColor = "#F2F2F2";
    t.style.borderStyle = "solid";
    t.style.borderWidth = "1px";
    t.style.borderColor = "#5858FA";
    t.innerHTML = "版块名<input type='text' onfocus='resumeStyle(this)' onkeydown='addTable(this)'/><input type='button' value='Save' onclick='addTable(this)'/><span style='cursor:default;' onclick='closeWindow(this.parentNode);'>X</span>";
    addEleAround(value, t, "same");
}
function addTable(value) {
    if (lib.getEvent().keyCode == 13 || value.type != "text") {
        var t = value.parentNode.getElementsByTagName("INPUT")[0];
        if (validateInput(t, /^\s*$/g) == false) {
            return;
        }
        var relationalID = value.parentNode.getAttribute("relationalID");
        var tableName = t.value;
        var a = new WebTable((new Date).getTime() + "TB", tableName, $("tdA"), g.page);
        var index = lib.data.getOrder(g.page.Tables, g.page.$(relationalID)) + 1;
        a.Parent.Tables.splice(index, 0, a);
        a.a(index);
        a.Parent.d();
        a.Parent.r();
        close(value.parentNode);
    }
}
function addEleAround(oldEle, newEle, orientation) {
    document.body.appendChild(newEle);
    var newLeft = newEle.offsetLeft;
    var newTop = newEle.offsetTop;
    var pos = findPos(oldEle);
    switch (orientation) {
        case "topleft":
            newEle.style.left = pos.absoluteLeft + "px";
            newEle.style.top = (pos.absoluteTop - newEle.offsetHeight) + "px";
            break;
        case "topright":
            newEle.style.left = (pos.absoluteLeft + oldEle.offsetWidth - newEle.offsetWidth) + "px";
            newEle.style.top = (pos.absoluteTop - newEle.offsetHeight) + "px";
            break;
        case "righttop":
            newEle.style.left = (pos.absoluteTop + oldEle.offsetWidth) + "px";
            newEle.style.top = pos.absoluteTop + "px";
            break;
        case "rightbottom":
            newEle.style.left = (pos.absoluteLeft - newEle.offsetWidth) + "px";
            newEle.style.top = (pos.absoluteTop + oldEle.offsetHeight - newEle.offsetHeight) + "px";
            break;
        case "bottomright":
            newEle.style.left = (pos.absoluteLeft + oldEle.offsetWidth - newEle.offsetWidth) + "px";
            newEle.style.top = (pos.absoluteTop + oldEle.offsetHeight) + "px";
            break;
        case "bottomleft":
            newEle.style.left = pos.absoluteLeft + "px";
            newEle.style.top = (pos.absoluteTop + oldEle.offsetHeight) + "px";
            break;
        case "leftbottom":
            newEle.style.left = (pos.absoluteLeft - newEle.offsetWidth) + "px";
            newEle.style.top = (pos.absoluteTop + oldEle.offsetHeight - newEle.offsetHeight) + "px";
            break;
        case "lefttop":
            newEle.style.left = (pos.absoluteLeft - newEle.offsetWidth) + "px";
            newEle.style.top = pos.absoluteTop + "px";
            break;
        case "same":
            newEle.style.left = pos.absoluteLeft + "px";
            newEle.style.top = pos.absoluteTop + "px";
            break;
    }
    return newEle;
}
function $SA() {
    var tmp = arguments[0];
    if (typeof tmpTagname === 'string') {
        return $(tmp).setAttribute(arguments[1], arguments[2]);
    }
    else {
        return tmp.setAttribute(arguments[1], arguments[2]);
    }
}
function $CE() {
    var tmpTagname = arguments[0];
    if (typeof tmpTagname === 'string') {
        return document.createElement(tmpTagname);
    }
}
function webClose(value) {
    closeWindow(value.parentNode);
}
function addWebAndClose(value) {
    var tmp = value.getAttribute("ParentID");
    var relationalIDs = value.getAttribute("relationalID").split("-");
    var webRow = lib.data.getObByAttribute(g.page.Tables, "ID", relationalIDs[0]).$(relationalIDs[1]);
    var tmpInputEles = value.parentNode.getElementsByTagName("INPUT");
    if ((validateInput(tmpInputEles[0], /^\s*$/g) && validateInput(tmpInputEles[1], /^\s*$/g) && validateInput(tmpInputEles[2], /^\s*$/g)) == false) {
        return;
    }
    webRow.o(new Web((new Date).getTime() + "Web", tmpInputEles[0].value, tmpInputEles[1].value, "Note test", webRow.CateName, "48778", tmpInputEles[2].value, ["cn", "en"], "A"), webRow.Webs.length);
    closeWindow(value.parentNode);
}
function showDeleteWeb(value) {
    var tmp = value.getAttribute("ID");
    g.volatileArray["showDeleteWeb"] = new settimeoutData(4000, tmp)
    setTimeout(delayShowDeleteWeb, 2000);
}
function delayShowDeleteWeb() {
    if (!g.volatileArray["showDeleteWeb"])
        return;
    var tmpWeb = getWebByIDWithPre(g.volatileArray["showDeleteWeb"].argument);
    delete g.volatileArray["showDeleteWeb"];
    tmpWeb.k(tmpWeb);
}
function deleteWeb() {
    var a = lib.formatEvent().target.getAttribute("relationalID").split("-");
    var t = g.page.$(a[0]).$(a[1]);
    lib.dom.setStyle(t.delButton, "cursor:default;visibility:hidden;");
    for (var i = 0; i < t.Webs.length; i++) {
        if (t.Webs[i].ID == t.Parent.selectWeb.ID) {
            t.Webs.splice(i, 1);
            t.d();
            t.r();
            t.lastOperateWeb = t.Parent.selectWeb;
            break;
        }
    }
}
function EditWeb(p) {
    var _ = this;
    Region.call(_);
    _.Ele = $CE("DIV");
    _.Ele.style.position = "absolute";
    _.Ele.style.backgroundColor = "#F2F2F2";
    _.Ele.style.borderStyle = "solid";
    _.Ele.style.borderWidth = "1px";
    _.Ele.style.borderColor = "#5858FA";
    if (typeof p == 'undefined') return;
    var a = g.mouseEvent;
    _.ID = "editor" + p.ID;
    $SA(_.Ele, "id", _.ID);
    $SA(_.Ele, "NameSourceValue", p.Name);
    $SA(_.Ele, "LinkSourceValue", p.Link);
    $SA(_.Ele, "relationalID", p.Parent.Parent.ID + "-" + p.Parent.ID + "-" + p.ID);
    var tmpEle = $CE("INPUT");
    tmpEle.type = "text";
    tmpEle.value = p.Name;
    tmpEle.size = p.Name.length;
    var tmpText = document.createTextNode("Name");
    _.Ele.appendChild(tmpText);
    _.Ele.appendChild(tmpEle);
    tmpEle = $CE("INPUT");
    tmpEle.type = "text";
    tmpEle.value = p.Link;
    tmpEle.size = p.Link.length;
    var tmpText = document.createTextNode("Link");
    _.Ele.appendChild(tmpText);
    _.Ele.appendChild(tmpEle);
    tmpEle = $CE("INPUT");
    tmpEle.value = p.Key ? p.Key : 5;
    tmpEle.size = tmpEle.value.length + 1;
    var tmpText = document.createTextNode("Key words");
    _.Ele.appendChild(tmpText);
    _.Ele.appendChild(tmpEle);
    tmpEle = $CE("INPUT");
    $SA(tmpEle, "type", "button");
    $SA(tmpEle, "relationalID", p.Parent.Parent.ID + "-" + p.Parent.ID + "-" + p.ID);
    $SA(tmpEle, "ParentID", _.ID);
    $SA(tmpEle, "onclick", "editorSaveAndClose(this)");
    tmpEle.value = "Save";
    _.Ele.appendChild(tmpEle);
    tmpEle = $CE("INPUT");
    $SA(tmpEle, "type", "button");
    $SA(tmpEle, "ParentID", _.ID);
    $SA(tmpEle, "onclick", "editorCancel(this)");
    tmpEle.value = "Reset";
    _.Ele.appendChild(tmpEle);
    tmpEle = $CE("INPUT");
    $SA(tmpEle, "type", "button");
    $SA(tmpEle, "ParentID", _.ID);
    $SA(tmpEle, "relationalID", p.Parent.Parent.ID + "-" + p.Parent.ID + "-" + p.ID);
    $SA(tmpEle, "onclick", "deleteWebTwo(this)");
    tmpEle.value = "Delete";
    _.Ele.appendChild(tmpEle);
    tmpEle = $CE("SPAN");
    $SA(tmpEle, "style", "cursor:default;");
    $SA(tmpEle, "ParentID", _.ID);
    $SA(tmpEle, "onclick", "editorSaveAndClose(this)");
    tmpEle.innerHTML = "X";
    _.Ele.appendChild(tmpEle);
    _.Ele = document.body.appendChild(_.Ele);
    p.EditEle = _.Ele;
    _.setRecByEle();
    var width = _.RecRight - _.RecLeft;
    var height = _.RecBottom - _.RecTop;
    if (p.RecLeft + width > document.body.scrollLeft + document.body.offsetWidth) {
        if (p.RecRight - width < document.body.scrollLeft) {
            _.Ele.style.left = document.body.scrollLeft + "px";
        }
        else {
            _.Ele.style.left = (p.RecRight - width) + "px";
        }
    }
    else {
        _.Ele.style.left = p.RecLeft + "px";
    }
    _.Ele.style.top = (p.RecTop - height) + "px";
}
function closeCateNameEditor(p) {
    if (lib.getEvent().keyCode == 13 || p.type != "text") {
        var tmpNameObj = p.parentNode.getElementsByTagName("INPUT")[0];
        if (validateInput(tmpNameObj, /^\s*$/g, "Error") == false) {
            return;
        }
        var tmpIDArray = p.parentNode.getAttribute("relationalID").split("-");
        var tmpTable = g.page.$(tmpIDArray[0]);
        var a = tmpTable.$(tmpIDArray[1]);
        a.CateName = tmpNameObj.value;
        a.CateNameEle.innerHTML = a.CateName;
        a.CateNameEle.style.visibility = "";
        p.parentNode.parentNode.removeChild(p.parentNode);
        a.Parent.lastOperateRow = a;
        a.u();
        a.r();
    }
}
function closeTableTitleEditor(p) {
    if (lib.getEvent().keyCode == 13 || p.type != "text") {
        var t = g.page.$(p.parentNode.getAttribute("ParentID"));
        t.Name = p.parentNode.getElementsByTagName("INPUT")[0].p;
        t.titleEle.innerHTML = t.Name;
        t.titleEle.style.visibility = "";
        p.parentNode.parentNode.removeChild(p.parentNode);
        t.u();
        t.r();
    }
}
function deleteRow() {
    var t = lib.formatEvent(arguments[0]).target.getAttribute("relationalID").split("-");
    var tmpTable = g.page.$(t[0]);
    var a = tmpTable.$(t[1]);
    var tmpCate = a.Parent.Categories;
    for (var i = 0; i < tmpCate.length; i++) {
        if (tmpCate[i].ID == a.ID) {
            tmpCate.splice(i, 1);
            a.Parent.Parent.d();
            a.Parent.d();
            a.Parent.r();
            a.Parent.lastOperateRow = a;
            break;
        }
    }
    a.f();
}
function editorSaveAndClose(value) {
    var tmpParentID = value.getAttribute("ParentID");
    var tmpEle = $(tmpParentID);
    var tmpID = "webElement2010" + tmpParentID.substring(6, tmpParentID.length);
    var relationalIDs = value.parentNode.getAttribute("relationalID").split("-");
    var tableID = relationalIDs[0];
    var rowID = relationalIDs[1];
    var webID = relationalIDs[2];
    var table = lib.data.getObByAttribute(g.page.Tables, "ID", tableID);
    var row = lib.data.getObByAttribute(table.Categories, "ID", rowID);
    var tmpWeb = row.$(webID);
    var tmpObjs = tmpEle.getElementsByTagName("INPUT");
    if ((validateInput(tmpObjs[0], /^\s*$/g, "Error") && validateInput(tmpObjs[1], /^\s*$/g, "Error")) == false) {
        return;
    }
    tmpWeb.Name = tmpObjs[0].value;
    tmpWeb.Link = tmpObjs[1].value;
    tmpWeb.Note = tmpObjs[2].value;
    tmpWeb.i();
    tmpWeb.h(tmpWeb);
    tmpEle.parentNode.removeChild(tmpEle);
    tmpWeb.EditEle = undefined;
}
function editorCancel(value) {
    var tmpEle = $(value.getAttribute("ParentID"));
    tmpEle.getElementsByTagName("INPUT")[0].value = tmpEle.getAttribute("NameSourceValue");
    tmpEle.getElementsByTagName("INPUT")[1].value = tmpEle.getAttribute("LinkSourceValue");
}
function deleteWebTwo(_para_ButtonEle) {
    var tmpIDArray = _para_ButtonEle.getAttribute("relationalID").split("-");
    var tmpTable = g.page.$(tmpIDArray[0]);
    var tmpRow = tmpTable.$(tmpIDArray[1]);
    var tmpWeb = tmpRow.$(tmpIDArray[2]);
    tmpWeb.g();
    tmpWeb.EditEle.parentNode.removeChild(tmpWeb.EditEle);
    tmpWeb.EditEle = undefined;
};
function editorDelete(value) {
    var tmpParentID = value.getAttribute("ParentID");
    var tmpEle = $(tmpParentID);
    var tmpWebID = tmpParentID.substring(6, tmpParentID.length);
    var tmpID = "webElement2010" + tmpWebID;
    var tmpWeb = getWebByIDWithPre(tmpID);
    var tmpRow = tmpWeb.Parent;
    lib.dom.setStyle(tmpRow.delButton, "cursor:default;visibility:hidden;");
    for (var i = 0; i < tmpRow.Webs.length; i++) {
        if (tmpRow.Webs[i].ID == tmpWebID) {
            tmpRow.Webs.splice(i, 1);
            tmpRow.d();
            tmpRow.r();
            tmpRow.lastOperateWeb = tmpWeb;
            break;
        }
    }
    tmpEle.parentNode.removeChild(tmpEle);
    tmpWeb.EditEle = undefined;
}
function findPos(obj) {
    if (u(obj))
        return;
    var curleft = curtop = 0;
    if (obj.offsetParent) {
        while (1) {
            curleft += obj.offsetLeft;
            curtop += obj.offsetTop;
            if (!obj.offsetParent) {
                break;
            }
            if (obj.style.position == "absolution") {
                break;
            }
            obj = obj.offsetParent;
        }
    }
    else if (obj.x && obj.y) {
        cureft += obj.x;
        curtop += obj.y;
    }
    return { "absoluteLeft": curleft, "absoluteTop": curtop };
}
function ForceWindow() {
    this.r = document.documentElement;
    this.f = $CE("FORM");
    this.f.target = "_blank";
    this.f.method = "post";
    this.r.insertBefore(this.f, this.r.childNodes[0]);
}
ForceWindow.prototype.open = function (sUrl) {
    this.f.action = sUrl;
    this.f.submit();
}
window.force = new ForceWindow();
function sendAndGetData(url, func) {
    try {
        xmlRequest.open("GET", url, false);
        xmlRequest.onreadystatechange = function () {
            if (xmlRequest.readyState == 4 && xmlRequest.status == 200) {
                func(xmlRequest.responseText);
            }
        };
        xmlRequest.send();
    }
    catch (e) {
        return false;
    }
}
var g_ComWithServer = new ComWithServer();
function ComWithServer() {
    this.dataToBeSent = new Array;
    this.dataHasBeenSent = new Array;
    this.dataToBeSentLen = 0;
    this.dataHasBeenSentLen = 0;
    this.totalLen = 0;
    function DataSent(index, indexInTOH, url, data) {
        this.index = index;
        this.indexInTOH = indexInTOH;
        this.url = url;
        this.data = data;
        this.hasSent = false;
    }
    this.add = function (url, data) {
        var oneDataSent = new DataSent(g_ComWithServer.totalLen, g_ComWithServer.dataToBeSentLen, url, data);
        this.dataToBeSent.push(oneDataSent);
    };
    this.sendReq = function (oneDataSent) {
        try {
            xmlRequest.open("POST", oneDataSent.url, true);
            xmlRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
            xmlRequest.setRequestHeader("Content-length", oneDataSent.data.length);
            xmlRequest.setRequestHeader("Connection", "close");
            var tmpDataToBeSent = g_ComWithServer.dataToBeSent;
            xmlRequest.onreadystatechange = function () {
                if (xmlRequest.readyState == 4 && xmlRequest.status == 200) {
                    if (xmlRequest.responseText.toLowerCase().indexOf("successed") > -1) {
                        g_ComWithServer.dataToBeSent.splice(0, 1)
                        g_ComWithServer.dataHasBeenSent.push(oneDataSent);
                        g_ComWithServer.dataHasBeenSentLen = g_ComWithServer.dataHasBeenSentLen + 1;
                        if (g_ComWithServer.dataToBeSent.length > 0) {
                            g_ComWithServer.sendReq(g_ComWithServer.dataToBeSent[0]);
                        }
                    }
                }
            };
            xmlRequest.send(oneDataSent.data);
        }
        catch (e) {
            alert(e);
            alert(oneDataSent.url);
        }
    };
    this.startSend = function () {
        g_ComWithServer.sendReq(g_ComWithServer.dataToBeSent[0]);
    };
    this.postData = function (_url, _data, _fun) {
        try {
            xmlRequest.open("POST", _url, true);
            xmlRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
            xmlRequest.setRequestHeader("Content-length", _data.length);
            xmlRequest.setRequestHeader("Connection", "close");
            xmlRequest.onreadystatechange = function () {
                if (xmlRequest.readyState == 4 && xmlRequest.status == 200) {
                    _fun(xmlRequest.responseText);
                }
            };
            xmlRequest.send(_data);
        }
        catch (e) {
            alert(e);
        }
    };
}
Object.prototype.Serialize = function () {
    var type = __typeof__(this);
    switch (type) {
        case 'Array':
            {
                var strArray = '[';
                for (var i = 0; i < this.length; ++i) {
                    var value = '';
                    if (this[i]) {
                        value = this[i].Serialize();
                    }
                    strArray += value + ',';
                }
                if (strArray.charAt(strArray.length - 1) == ',') {
                    strArray = strArray.substr(0, strArray.length - 1);
                }
                strArray += ']';
                return strArray;
            }
        case 'Date':
            {
                return 'new Date(' + this.getTime() + ')';
            }
        case 'Boolean':
        case 'Function':
        case 'Number':
            return this.toString();
        case 'String':
            {
                return '"' + this.toString() + '"';
            }
        default:
            {
                var serialize = '{';
                for (var key in this) {
                    if (key == 'Serialize') continue;
                    var subserialize = 'null';
                    if (!u(this[key])) {
                        subserialize = this[key].Serialize();
                    }
                    serialize += '\r\n' + key + ' : ' + subserialize + ',';
                }
                if (serialize.charAt(serialize.length - 1) == ',') {
                    serialize = serialize.substr(0, serialize.length - 1);
                }
                serialize += '\r\n}';
                return serialize;
            }
    }
};
function __typeof__(p) {
    if (p && p.constructor) {
        var a = p.constructor.toString();
        return a.substr(0, a.indexOf('(')).replace('function', '').replace(/(^\s*)|(\s*$)/ig, '');
    }
    return typeof (p);
}
g.selectedData.m = function () {
    if (!u(this.tableData) && !u(this.rowData) && !u(this.webData)) {
        this.webData.Ele.style.backgroundColor = "#B0E0E6";
    }
};
g.selectedData.resume = function () {
    if (!u(this.webData)) {
        this.webData.Ele.style.backgroundColor = "#DDEEDD";
    }
};
function close(value) {
    if (value == null || u(value) || u(value.parentNode)) return;
    value.parentNode.removeChild(value);
}
function closeWindow(value) {
    if (u(value.parentNode)) {
        return;
    }
    value.parentNode.removeChild(value);
}
function validateInput(obj, reg, msg) {
    if (obj.value == "" || reg.test(obj.value)) {
        obj.style.color = "Red";
        obj.value = (u(msg)) ? "Please input the correct data" : msg;
        return false;
    }
    return true;
}
function resumeStyle(obj, uselessMSG) {
    obj.style.color = "#000000";
}
function yellowTip(msg) {
    var ele = $("yellowTip");
    if (u(ele)) {
        ele = $CE("DIV");
        $SA(ele, "style", "background-color:yellow;");
        ele.innerValue = msg;
        document.body.appendChild(ele);
    }
    else {
        document.body.removeChild(ele);
    }
}
function addWeb() {
    var trigger = lib.formatEvent(arguments[0]).target;
    var tmpIDs = trigger.getAttribute("relationalID").split("-");
    var webRow = g.page.$(tmpIDs[0]).$(tmpIDs[1]);
    if (webRow.editAndAddEle.parentNode == null || webRow.editAndAddEle.parentNode.parentNode == null) {
        webRow.n();
    }
    else {
        closeWindow(webRow.editAndAddEle);
    }
}
function LightOn(ele) {
    lib.transparentDiv.on();
    var contentDiv = $CE("div");
    var top = parseInt(parseInt(document.body.scrollHeight) * 0.25) + document.body.scrollTop;
    contentDiv.style.position = "absolute";
    contentDiv.style.width = "300px";
    contentDiv.id = "contentDiv";
    var left = Math.ceil(((document.body.scrollWidth) - parseInt(contentDiv.style.width.replace('px', ''))) / 2)
+ document.body.scrollLeft;
    contentDiv.style.zIndex = "9";
    contentDiv.style.top = top + "px";
    contentDiv.style.left = left + "px";
    contentDiv.style.border = "0px solid red";
    document.body.appendChild(contentDiv);
    var tmp = lib.lognModule.getInstance();
    contentDiv.innerHTML = lib.lognModule.getInstance();
    var tmpURL = g.domainDirectory + "/reglog.js?freshParam=" + (new Date).getTime();
    sendAndGetData(true, tmpURL, function (resTxt) {
        eval(resTxt);
    });
    var arr = document.getElementsByTagName("select");
    var i = 0;
    while (i < arr.length) {
        arr[i].style.visibility = "hidden";
        i++;
    }
    this.cancle = function () {
        if (!u($("transparentDiv"))) {
            document.body.removeChild($("transparentDiv"));
        }
        var tmp = $("contentDiv");
        tmp.parentNode.removeChild(tmp);
        var arr = document.getElementsByTagName("select");
        var i = 0;
        while (i < arr.length) {
            arr[i].style.visibility = "visible";
            i++;
        }
    }
}
function lightboxSetBlack(ele) {
    var scrW;
    var scrH;
    if (window.innerHeight && window.scrollMaxY) {
        scrW = window.innerWidth + window.scrollMaxX;
        scrH = window.innerHeight + window.scrollMaxY;
    }
    else if (document.body.scrollHeight > document.body.offsetHeight) {
        scrW = document.body.scrollWidth;
        scrH = document.body.scrollHeight;
    }
    else if (document.body) {
        scrW = document.body.offsetWidth;
        scrH = document.body.offsetHeight;
    }
    ele.style.display = "block";
    ele.style.width = scrW;
    ele.style.height = scrH;
}
function hideTab(ele) {
    ele.style.display = 'none';
}
function minimize(ele) {
    ele.style.width = 0;
    ele.style.height = 0;
}
function signOnOrSignIn(index) {
    var signonTab = $("signonTab");
    var signinTab = $("signinTab");
    if (index == 1) {
        signinTab.style.display = "";
        signonTab.style.display = "none";
    }
    else {
        signinTab.style.display = "none";
        signonTab.style.display = "";
    }
}
function showTab(tabHeadId, tabContentId) {
    var tabDiv = document.getElementById("light");
    var taContents = tabDiv.childNodes;
    for (var i = 0; i < taContents.length; i++) {
        if (taContents[i].id != null && taContents[i].id != 'tabsHead') {
            taContents[i].style.display = 'none';
        }
    }
    document.getElementById(tabContentId).style.display = 'block';
    var tabHeads = document.getElementById('tabsHead').getElementsByTagName('a');
    for (var i = 0; i < tabHeads.length; i++) {
        tabHeads[i].className = 'tabs';
    }
    document.getElementById(tabHeadId).className = 'curtab';
    document.getElementById(tabHeadId).blur();
}
function triggerSearchLocal(e) {
    var tmpEve = lib.formatEvent(e);
    if (tmpEve.keyCode == 13) {
        searchLocal();
    }
}
function searchLocal() {
    var tmpKey = $("webKeywordID").value;
    var tmpUrl;
    if (tmpKey.replace(/^\s*/, "") == "") {
        createWebTable(g.dataWebTable["main"]);
        return;
    }
    if (u(g.dataWebTable["search" + tmpKey])) {
        tmpUrl = g_domainURL + "/search.aspx?key=" + escape(tmpKey) + "&&f=" + (new Date).getTime();
        sendAndGetData(true, tmpUrl, function (_resData) {
            if (_resData == "") {
            }
            else {
                g.dataWebTable["search" + tmpKey] = eval('(' + _resData + ')');
                createWebTable(g.dataWebTable["search" + tmpKey]);
                g.state["search"] = true;
            }
        });
    }
    else {
        createWebTable(g.dataWebTable["search" + tmpKey]);
    }
}
function testFunc() {
    g.fun();
}